const path = require('path')
const {smart} = require('webpack-merge')
const base = require('./webpack.base.js')
const Webpack = require('webpack')

module.exports = smart(base,{
	mode:'development',
	
	/* 出口文件 */
	output: {
		filename: 'js/[name].[hash:8].js',
		chunkFilename:'js/[name].[hash:8].js',
		path: path.resolve(__dirname, 'dev'),
	},
	
	/* webpack测试服务器 */
	devServer:{	
		port:'3000',
		contentBase:__dirname+"/dev",
		open:true,
		compress:true,
		inline: true,
		before(app){	//接口模拟钩子
			app.get('/user',(req,res)=>{
				res.json({name:'HuiSer',age:'19'})
			})
		},
	},
	
	/* source-map */
	devtool:'source-map',
	
	plugins:[
		/* 定义环境变量 */
		new Webpack.DefinePlugin({
			GLOBAL:{
				host:JSON.stringify('192.168.1.1:8080'),	//域
			}
		}),
	]
})